package com.boot.service.impl;

import com.boot.bean.RoomDo;
import com.boot.repository.RoomRepository;
import com.boot.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.*;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoomServiceImpl implements RoomService {
    @Autowired
    private RoomRepository roomRepository;

    @Override
    public RoomDo save(RoomDo model) {
        return roomRepository.save(model);
    }

    @Override
    public Integer deleteById(int id) {
        return 0;
    }

    @Override
    public RoomDo findById(int id) {
        return null;
    }

    @Override
    public Page<RoomDo> findAll(Integer page, Integer size) {
        return null;
    }

    @Override
    public Page<RoomDo> findAll(RoomDo model, Integer page, Integer size) {
        Sort sort = new Sort(Sort.Direction.DESC, "createDate");
        Pageable pageable = PageRequest.of(page,size,sort);
        Example<RoomDo> example = Example.of(model);
        return roomRepository.findAll(example,pageable);
    }
}
